package com.erp.app.catalog.login.web;

import com.erp.app.catalog.itemMaster.vo.ItemMasterDtlVO;
import com.erp.app.catalog.itemMaster.vo.ItemMasterPicVO;
import com.erp.app.catalog.itemMaster.vo.ItemMasterVO;
import com.erp.app.common.ProjectConstants;
import com.erp.app.common.query.BeanQuery;

import com.erp.framework.SimpleConstants;
import com.erp.framework.controller.form.SimpleSearchStyleFormTemplate;
import com.erp.framework.util.CommonUtil;

import java.util.ArrayList;
import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;

public class CatalogLoginForm extends SimpleSearchStyleFormTemplate{
	private String srchCompanyCode;
	
	private String srchMainCat;
	private String pageHeaderMainCat;
	private String srchArticleNo;
	private String srchDesc;
	private String[] srchSubCat;
	private String[] srchSubCatDtl;

	private String mainShowType = "LOGIN";
	private String showType = "LIST";
	private String currShowType;
	
	private ArrayList categoryItemLineVos;
	
	private ArrayList itemMasterVos;
	
	private ArrayList cateMenuList; 
	
	private String subject;
	private String body;
	
	private String EmailWebLink;
    
	private ItemMasterVO itemMasterVO;
	
	private ArrayList parentItemMasterVO;
	private ArrayList childItemMasterVO;
	
	private int ttlPage;	
	
	private byte[] attachPic;
	
	private int currPicIdx = 0;
	
	public int getCurrPicIdx() {
		return currPicIdx;
	}
	public void setCurrPicIdx(int currPicIdx) {
		this.currPicIdx = currPicIdx;
	}
	public int getTtlPage() {
		return ttlPage;
	}
	public void setTtlPage(int ttlPage) {
		this.ttlPage = ttlPage;
	}
	
	public String getBody() {
		return body;
	}
	public void setBody(String body) {
		this.body = body;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getSrchMainCat(){
		return this.srchMainCat;
	}
	public String getPageHeaderMainCat(){
		return this.pageHeaderMainCat;
	}
	public String getSrchArticleNo(){
		return this.srchArticleNo;
	}
	public String[] getSrchSubCat(){
		return this.srchSubCat;
	}
	public String[] getSrchSubCatDtl(){
		return this.srchSubCatDtl;
	}
	public String getMainShowType(){
		return this.mainShowType;
	}
	public String getShowType(){
		return this.showType;
	}
	public ArrayList getCategoryItemLineVos(){
		return this.categoryItemLineVos;
	}
	
	public ArrayList getItemMasterVos(){
		return this.itemMasterVos;
	}
	
	public void setSrchMainCat(String srchMainCat){
		this.srchMainCat = srchMainCat;
	}
	public void setPageHeaderMainCat(String pageHeaderMainCat){
		this.pageHeaderMainCat = pageHeaderMainCat;
	}
	public void setSrchArticleNo(String srchArticleNo){
		this.srchArticleNo = srchArticleNo;
	}
	public void setSrchSubCat(String[] srchSubCat){
		this.srchSubCat = srchSubCat;
	}
	public void setSrchSubCatDtl(String[] srchSubCatDtl){
		this.srchSubCatDtl = srchSubCatDtl;
	}
	public void setMainShowType(String mainShowType){
		this.mainShowType = mainShowType;
	}
	public void setShowType(String showType){
		this.showType = showType;
	}
	public void setCategoryItemLineVos(ArrayList categoryItemLineVos){
		this.categoryItemLineVos = categoryItemLineVos;
	}
	
	public void setItemMasterVos(ArrayList itemMasterVos){
		this.itemMasterVos = itemMasterVos;		
	}

	public String[] getItemLineDesc(){
		String[] itemLineDesc = null;		
		return itemLineDesc;
	}

	public Iterator getItemLineDescValues(){
		String query = " SELECT ITEM_LINE, ITEM_LINE_DESC "
                + " FROM V_CATEGORY_ITEM_LINE "
                + " WHERE A.STATUS = '" + SimpleConstants.GENERIC_ACTIVE + "' "
			    + " AND A.SHOW_IN_CATALOG = '" + SimpleConstants.GENERIC_YES + "' ";
        return this.getTemplate().getComboboxValues(new BeanQuery(query).setModel(this));
	}
	public ItemMasterVO getItemMasterVO() {
		return itemMasterVO;
	}
	public void setItemMasterVO(ItemMasterVO itemMasterVO) {
		this.itemMasterVO = itemMasterVO;
	}
	public String getEmailWebLink() {
		return EmailWebLink;
	}
	public void setEmailWebLink(String emailWebLink) {
		EmailWebLink = emailWebLink;
	}
	public String getSrchDesc() {
		return srchDesc;
	}
	public void setSrchDesc(String srchDesc) {
		this.srchDesc = srchDesc;
	}
	public int getCurrentPage(){
		return (int)Math.ceil((this.sidx+1)*1.0/CatalogLoginAction.MAX_SHOW_PAGE);
	}
	
	public String getCurrShowType() {
		return currShowType;
	}
	public void setCurrShowType(String currShowType) {
		this.currShowType = currShowType;
	}
	
	public ArrayList getCateMenuList() {
		return cateMenuList;
	}
	public void setCateMenuList(ArrayList cateMenuList) {
		this.cateMenuList = cateMenuList;
	}
	public ArrayList getChildItemMasterVO() {
		return childItemMasterVO;
	}
	public void setChildItemMasterVO(ArrayList childItemMasterVO) {
		this.childItemMasterVO = childItemMasterVO;
	}
	public ArrayList getParentItemMasterVO() {
		return parentItemMasterVO;
	}
	public void setParentItemMasterVO(ArrayList parentItemMasterVO) {
		this.parentItemMasterVO = parentItemMasterVO;
	}
	public String getSrchCompanyCode() {
		return srchCompanyCode;
	}
	public void setSrchCompanyCode(String srchCompanyCode) {
		this.srchCompanyCode = srchCompanyCode;
	}
	public byte[] getAttachPic() {
		return attachPic;
	}
	public void setAttachPic(byte[] attachPic) {
		this.attachPic = attachPic;
	}
	
	public String getSearchImageFile(HttpServletRequest request, ItemMasterVO vo, int idx){
		String imageFile = request.getContextPath() 
		+ ProjectConstants.DEFAULT_NO_FOUND_PRODUCT_IMAGE_PATH + "/"
		+ ProjectConstants.DEFAULT_NO_FOUND_PRODUCT_IMAGE_NAME;
		
		if(!CommonUtil.isEmpty(vo.getAttachment())){
			imageFile = "catalogLogin.do?pageEvent=showAttachPic&pageEventSrc="+idx;
		}
		
		return imageFile;
	}

	public String getMaintImageFile(HttpServletRequest request, ItemMasterPicVO vo, int idx){
		String imageFile = request.getContextPath() 
			+ ProjectConstants.DEFAULT_NO_FOUND_PRODUCT_IMAGE_PATH + "/"
			+ ProjectConstants.DEFAULT_NO_FOUND_PRODUCT_IMAGE_NAME;
		if(vo != null && !CommonUtil.isEmpty(vo.getLv2Attachment())){
			imageFile = "catalogLogin.do?pageEvent=showDtlAttachPic&pageEventSrc="+idx;		
		}
		
		return imageFile;
	}
	public String prevPicButtonOnCilck(int idx){
		StringBuffer onClick = new StringBuffer();
		
		if (idx > 0){
			onClick.append("img"+(idx-1)+".style.display='';");
			onClick.append("btn"+(idx-1)+".style.display='';");
		}
		onClick.append("img"+idx+".style.display='none';");
		onClick.append("btn"+idx+".style.display='none';");
		
		return onClick.toString();
	}
	
	public String nextPicButtonOnCilck(int idx, int size){
		StringBuffer onClick = new StringBuffer();
		
		if (idx != size-1){
			onClick.append("img"+(idx+1)+".style.display='';");
			onClick.append("btn"+(idx+1)+".style.display='';");
		}
		onClick.append("img"+idx+".style.display='none';");
		onClick.append("btn"+idx+".style.display='none';");
		
		return onClick.toString();
	}
}